﻿namespace KinonekoSoftware.Studio.Models.Instances.Team
{
    public sealed class TeamDOLPresenter : ObservableObject
    {
        private bool _isDisplayMode;
        
        public TeamDOLPresenter(TeamDOL target)
        {
            Target  = target ?? throw new ArgumentNullException(nameof(target));
            Members = new ObservableCollection<InstanceCache>();
        }

        public void Initialize(InstanceCacheEngine engine)
        {
            foreach (var member in Target.Members)
            {
                //
                //
                Members.Add(engine.Get(member));
            }
            
            RaiseUpdated(nameof(Title));
            RaiseUpdated(nameof(Intro));
        }

        public TeamDOL Target { get; }

        public string Id => Target.Id;

        public string Title
        {
            get => Target.Title;
            set
            {
                Target.Title = value;
                RaiseUpdated();
            }
        }

        public string Intro
        {
            get => Target.Intro;
            set
            {
                Target.Intro = value;
                RaiseUpdated();
            }
        }

        //
        //
        public bool IsDisplayMode
        {
            get => _isDisplayMode;
            set => SetValue(ref _isDisplayMode, value);
        }
        
        //
        //
        public ObservableCollection<InstanceCache> Members { get; }
    }
}